package com.fh.service.impl;/**
 * 描述:
 * Author:袁亚强
 * Date:2021/11/2216:45
 */

import com.fh.common.TableData;
import com.fh.entity.po.Key;
import com.fh.entity.vo.Result;
import com.fh.mappers.KeyMapper;
import com.fh.service.KeyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * created by macro on 2021/11/22,
 */
@Service
public class KeyServiceImpl implements KeyService {
    @Resource
    private KeyMapper keyMapper;
    @Override
    public Key queryByIdData(Integer id) {
        return keyMapper.queryByIdData(id);
    }

    @Override
    public void updateKey(Key key) {
        keyMapper.updateKey(key);
    }

    @Override
    public void addKey(Key key) {
        key.setCreateDate(new Date());
        key.setIsdel(0);
        keyMapper.addKey(key);
    }

    @Override
    public TableData<Key> queryPageData(Result result) {
        return new TableData<>(keyMapper.queryCount(result),keyMapper.queryKeyList(result));
    }

    @Override  //0存在 1不存在
    public Integer queryByName(String name,Integer tid) {
        return keyMapper.queryByName(name,tid)!=null?0:1;
    }
}
